package com.pinoc.demo.utils;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLEncoder;

/**
 * @author yinpeng
 */
public class HtmlParseUtil {

	public static void main(String[] args) throws IOException {
		String url = "https://search.jd.com/Search?keyword=lanqiu";
		Document parse = Jsoup.connect(url).get();
		Element j_goodsList = parse.getElementById("J_goodsList");
		System.out.println(j_goodsList);
		Elements li = j_goodsList.getElementsByTag("li");
		for (Element element : li) {
			String text = element.getElementsByClass("p-price").eq(0).text();
			String name = element.getElementsByClass("p-name").eq(0).text();
			System.out.println(text +"  " + name);
		}
	}
}
